<?php
/**
  * 相册模型
  */ 
class AlbumModel extends CommonModel{

	protected $_validate=array(
		array('title','require','标题必须！',self::MODEL_BOTH)
		);

	protected $_auto=array(
		array('edit_time','time',self::MODEL_BOTH,'function'),
		array('add_time','callbackTime',self::MODEL_INSERT,'callback'),
	    array('seo_description','callbackDescription',self::MODEL_BOTH,'callback'),
	    array('brief','callbackBrief',self::MODEL_BOTH,'callback'),
	    array('status','callbackStatus',self::MODEL_UPDATE,'callback') 
		);

	protected function callbackTime()
	{
	  return date('Y-m-d',time());
	}

	protected function callbackDescription()
	{
	  if($_POST['seo_description'])
	  {
		  $temp=$_POST['seo_description'];
	  }else
		  {
			if($_POST['brief'])
			{
				$temp=$_POST['brief'];
			}else
				{
					$temp=msubstr(str_replace("&nbsp;",'',strip_tags($_POST['content'])),0,150);
				}
		  }
	  return $temp;
	}

	protected function callbackBrief()
	{
		if($_POST['brief'])
		{
			$temp=$_POST['brief'];
		}else
			{
				$temp=msubstr(trim(str_replace(" ",'',strip_tags($_POST['content']))),0,200);
			}
		return $temp;
	}

	protected function callbackStatus()
	{
	  if(isset($_POST['status']))
	  {
	  	return 1;
	  }else{return 0;}
	}

}
?>